package com.csxy.six.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.csxy.six.entity.ReadLog;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

@Mapper
public interface ReadLogMapper extends BaseMapper<ReadLog> {
    /**
     * 插入或更新阅读记录
     * @param userId 用户ID
     * @param announceId 公告ID
     *
     */
    @Insert("INSERT INTO read_log (user_id, announce_id, read_time) " +
            "VALUES (#{userId}, #{announceId}, NOW()) " +
            "ON DUPLICATE KEY UPDATE read_time = NOW()")
    int insertOrUpdate(@Param("userId") Integer userId,
                       @Param("announceId") Integer announceId);
}
